#pragma once

class Sound;
class Music;

class CMixer final :
	public IEngMod,
	public IRender,
	public ICalc,
	public ICriticalSection
{
public:
	CMixer();
	~CMixer();

	/*-IRender------------------------------------------------------------------*/
	virtual void OnRender(const RenderTask* renderTask, uint camarg) override;

	/*-ICalc--------------------------------------------------------------------*/
	virtual void OnCalc(uint arg) override;

	/*-ICriticalSection---------------------------------------------------------*/
	enum CriticalSection
	{
	    Soundtrack
	};

	/*--------------------------------------------------------------------------*/

	void PlayNow(const Sound* sound);
	void PlayNow(const Music* music);

	void StopMusicFade(int ms);
	void StepMusic();

	void AddToSoundtrack(const std::string& name);
	void AddToSoundtrack(const Music* music);
	void ClearSoundtrack();
	void StartPlayingSoundtrack();

	void OnMusicStop();

private:
	int m_channel;

	std::string m_displayedLabel;

	bool m_playingSoundtrack;
	uint m_soundtrackNumber;
	std::vector<const Music*> m_soundtrack;
};

void OnMusicStopHook();

namespace sh
{
void playmusic(const std::string& name);
void playchunk(const std::string& name);
};

extern CMixer* g_Mixer;